*** LOAD DATA
import delimited grbg_replication_210604, clear
xtset mc year
*** FIGURE 1.
tab mayoralparty, matcell(xxx)
matrix list xxx
 svmat xxx
 
 gen valmayoralparty=.
 replace valmayoralparty=1 in 1
 replace valmayoralparty=2 in 2
 replace valmayoralparty=3 in 3
 replace valmayoralparty=4 in 4
 replace valmayoralparty=5 in 5
 replace valmayoralparty=7 in 6
 replace valmayoralparty=8 in 7
 replace valmayoralparty=6 in 8
 
logit tcritique i.mayoralparty, cluster(mc) or
margins mayoralparty, post
 est store mayoralparty
 
reg mayoralparty mayoralparty
est store mayoralparty6
reg mayoralparty mayoralparty
est store mayoralparty7

sum tcritique

 coefplot (mayoralparty) (mayoralparty6, keep(_cons) offset(.025)) (mayoralparty7, keep(_cons) offset(1.025)), citype(logit) ///
 	vertical mlc(black) m(S) mc(black) msize(large) lp(solid) lwidth(thick) ciopt(lcolor(black) recast(rcap) lwidth(medthick)) ///
	plotregion(style(none) m(l=0 r=2 t=0 b=0)) graphregion(m(tiny)) ///
	ylabel(0(.1).6, tlc(white) labs(medium) grid glcolor(gs10)) legend(off) ///
	xsc(r(1 8) noline) xlab(1 "S" 2 "M" 3 "C" 4 "CD" 5 "L" 6 "Other" 7 "LP" 8 "GP", notick) ysc(r(-.01 .62) noline axis(1) alt) yline(`r(mean)', lp(dash)) text(.285 7.5 "Sample mean") ///
	xsize(5) ysize(3) addplot(sc xxx1 valmayoralparty, yaxis(2) ytitle("Frequency", size(medlarge) axis(2)) ysc(r(-10 620) noline alt axis(2)) ylab(0(100)600, notick axis(2)) below mlabel(mc) recast(bar) bc(none) lw(medium) mlc(gs6) barw(.5))
	
*** TABLE 1. 
reg dvsmp tcritique  , cluster(mc) 
reg dvsmp tcritique  c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralparty i.term , cluster(mc) 
reg dvsmpdiff  tcritique  c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralparty i.term , cluster(mc) 
xtreg pvsmp tcritique  , cluster(mc) fe
xtreg pvsmp tcritique  c.kol_respc##c.kol_respc  scb_meaninc scb_openunemp scb_muntax_te i.mayoralparty i.term , cluster(mc) fe
xtreg pvsmpdiff  tcritique  c.kol_respc##c.kol_respc scb_meaninc scb_openunemp scb_muntax_te i.mayoralparty i.term , cluster(mc) fe

*** TABLE 2.
logit mpreelected tcritique  if dvsmp!=., cluster(mc) or
logit mpreelected  tcritique   c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother	i.term logscb_pop , cluster(mc) or
logit mpreelected  tcritique  c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother i.term logscb_pop pvsmp  , cluster(mc) or 
xtlogit mpreelected tcritique  if dvsmp!=., fe or
xtlogit mpreelected  tcritique c.kol_respc##c.kol_respc  scb_meaninc scb_openunemp scb_muntax_te i.mayoralpartympother i.term logscb_pop , fe or
xtlogit mpreelected  tcritique c.kol_respc##c.kol_respc  scb_meaninc scb_openunemp scb_muntax_te i.mayoralpartympother i.term logscb_pop pvsmp , fe or

*** FIGURE 2. 
quietly logit mpreelected i.tcritique c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother	 i.term , cluster(mc) or
margins , at(tcritique=0) post
est store diff1
	est store m1
quietly logit mpreelected i.tcritique c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother	 i.term , cluster(mc) or
margins, at(tcritique=1) post
	est store m2
quietly logit mpreelected i.tcritique c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother	 i.term , cluster(mc) or
margins , dydx(tcritique) post
	scalar diff1 = el(r(b),1,2)
	local b1 : di %6.3f scalar(diff1)
 	
quietly logit mpreelected i.tcritique c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother	 i.term pvsmp , cluster(mc) or
margins, at(tcritique=0) post
	est store m3
quietly logit mpreelected i.tcritique c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother	 i.term pvsmp , cluster(mc) or
margins, at(tcritique=1) post
	est store m4
quietly logit mpreelected i.tcritique c.sumkol_respc##c.sumkol_respc anntenurediffscb_meaninc anntenurediffscb_openunemp tenurediffscb_muntax_te i.mayoralpartympother	 i.term pvsmp , cluster(mc) or
margins , dydx(tcritique) post
	scalar diff2 = el(r(b),1,2)
	local b2 : di %6.3f scalar(diff2)
coefplot ///
	(m1, fc(gs2) offset(-.31) 	recast(bar) barwidth(0.15) fc(gs6)	lcolor(black) lwidth(medium) ciopts(lcolor(black) 	recast(rcap) lwidth(medthick))) ///
	(m2, fc(gs2) offset(-.19)	recast(bar) barwidth(0.15) fc(white) lcolor(black) lwidth(medium) ciopts(lcolor(black) 	recast(rcap) lwidth(medthick))) ///
	(m3, fc(gs8) offset(.19) recast(bar) barwidth(0.15) fc(gs6) 	lcolor(black) lwidth(medium) ciopts(lcolor(gs2) 	recast(rcap) lwidth(medthick))) ///
	(m4, fc(gs8) offset(.31) 	recast(bar) barwidth(0.15) fc(white) lcolor(black) lwidth(medium) ciopts(lcolor(gs2) 	recast(rcap) lwidth(medthick))) ///
	, vertical  plotregion(style(none) m(l=0 r=0 t=2 b=0)) graphregion(m(tiny))  msize(large) ///
		citype(logit) citop     ///
		xscale(noline)  xlabel(.75 "Baseline" 1.25 "With control for Vote share{subscript:t+1}", tlc(white) labsize(medlarge) ) ///
		ylabel(0(.1).8, tlc(white) labs(medium) grid glcolor(gs10)) yscale(r(0 .8) noline) ytitle("Probability of re-election", height(5) size(medlarge)) ///
		legend(region(lstyle(none) m(l=0 r=0 t=0 b=0)) order(1 3) label(1 "No critique") label(3 "Critique") size(medium)) ///
		text(.69 .83 	"}" 	, placement(e) size(7))	///
		text(.685 .855 	"{&Delta}=`b1'"	, placement(e) size(4))		///
		text(.69 1.33 	"}" 	, placement(e) size(7))	///
		text(.685 1.355 "{&Delta}=`b2'"	, placement(e) size(4))		///
		xsize(4) ysize(3) 
